package com.blog.backend.gateWayController;

import com.blog.backend.req.FoodReq;
import com.blog.backend.req.ListFoodReq;
import com.blog.backend.resp.DoorHotFoodResp;
import com.blog.backend.resp.FoodResp;
import com.blog.backend.service.FoodService;
import com.blog.backend.utils.Result;
import com.blog.backend.vo.PageRequest;
import com.blog.backend.vo.PageResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/food")
public class DoorFoodController {

    @Resource
    private FoodService foodService;

    @GetMapping("/getHotFoodList")
    public Result<DoorHotFoodResp> getHotFoodList(){
        DoorHotFoodResp resp = foodService.getHotFoodList();
        return Result.success(resp);
    }


    @PostMapping("/getDoorFoodList")
    public Result<PageResult<FoodResp>> getDoorFoodList(@RequestBody ListFoodReq request){
        request.setStatus(2);
        PageResult<FoodResp> pageResult= foodService.getDoorFoodList(request);
        return Result.success(pageResult);
    }

    @GetMapping("/getDoorFoodDetail")
    public Result<FoodResp> getDoorFoodDetail(@RequestParam String foodId){
        FoodResp resp = foodService.selectFoodDetail(foodId);
        return Result.success(resp);
    }
}
